package com.yrk.dao.impl;

import com.yrk.dao.EmpDao;
import com.yrk.entity.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component("namedTempl")
public class NamedDaoTemplImpl implements EmpDao {
    @Autowired
    private NamedParameterJdbcTemplate namedJdbcTemplate;
    @Override
    public List<Emp> getEmpAll() {
        return Collections.emptyList();
    }

    @Override
    public List<Emp> getEmpByName(String empName) {
        return Collections.emptyList();
    }

    @Override
    public int insertEmp(Emp emp) {
        String sql = "insert into emp(ename,job,sal) values(:ename,:job,:sal)";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("ename", emp.getEname());
        params.put("job", emp.getJob());
        params.put("sal", emp.getSal());
        return namedJdbcTemplate.update(sql,params);
    }
}
